package web.gkw.action;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import web.gkw.model.General;
import web.gkw.service.GeneralService;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class Sense extends ActionSupport {
	
	@Resource
	private GeneralService generalService;

	public GeneralService getGeneralService() {
		return generalService;
	}

	public void setGeneralService(GeneralService generalService) {
		this.generalService = generalService;
	}
	
	private List<General> list;
	private int page;
	private int pages;
	private General sense;
	private int id;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public General getSense() {
		return sense;
	}

	public void setSense(General sense) {
		this.sense = sense;
	}

	public int getPages() {
		return pages;
	}

	public void setPages(int pages) {
		this.pages = pages;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public List<General> getList() {
		return list;
	}

	public void setList(List<General> list) {
		this.list = list;
	}
	
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		pages = generalService.getGeneralCount();
		if(page == 0) {
			page = 1;
		}
		list = generalService.getGeneralFirst(page);
		return "success";
	}
	
	public String show() {
		sense = generalService.getGeneral(id);
		return "show";
	}
	
}
